package com.sskj.run.presenter;

import com.lzy.okgo.model.Response;
import com.sskj.common.base.HttpData;
import com.sskj.common.util.ToastUtil;
import com.sskj.lib.http.JsonCallBack;
import com.sskj.run.bean.ExchangeUsable;
import com.sskj.run.http.HttpConfig;
import com.sskj.run.ui.activity.TransferActivity;

/**
 * Created by QinKang on 2019/1/2.
 */

public class RechargePresenter extends BasePresenter<TransferActivity> {





    public void exchange(String formWalletType, String toWalletType, String rotationNum, String payment_password, String id) {
        httpService.exchange(formWalletType, toWalletType, rotationNum, payment_password, id)
                .execute(new JsonCallBack<HttpData>(this) {
                    @Override
                    public void onSuccess(Response<HttpData> response) {
                        HttpData httpData = response.body();
                        ToastUtil.showShort(httpData.getMsg());
                        if (httpData.getStatus() == HttpConfig.OK) {
                            mView.exchangeSuccess();
                        }
                    }
                });
    }
    public void getUsable(String formWalletType, String id) {
        httpService.getExchangeUsable(formWalletType, id)
                .execute(new JsonCallBack<HttpData<ExchangeUsable>>() {
                    @Override
                    public void onSuccess(Response<HttpData<ExchangeUsable>> response) {
                        HttpData<ExchangeUsable> httpData = response.body();
                        if (httpData.getStatus() == HttpConfig.OK) {

                            mView.updateUsable(httpData.getData().getUsable());
                        }
                    }
                });
    }

}
